const path = require('path');
const resolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const typescript = require('@rollup/plugin-typescript');
const copy = require('rollup-plugin-copy');
const alias = require('@rollup/plugin-alias');

module.exports = {
    input: path.resolve(__dirname, './src/index.ts'),
    output: {
        file: path.resolve(__dirname, './bundle/index.js'),
        format: 'cjs'
    },
    plugins: [
        resolve({
            mainFields: ['main', 'module']
        }),
        commonjs(),
        typescript(),
        copy({
            targets: [{ src: 'src/package', dest: 'bundle' }]
        }),
        alias([{ find: '@', replace: path.resolve(__dirname, './src') }])
    ],
    watch: {
        include: ['src/**'],
        exclude: ['src/package']
    }
};
